<!-- include style -->
<html>
<head>
<link rel="stylesheet" href="../../assets/css/bootstrap.css"
	type="text/css" />
<link rel="stylesheet" href="../../assets/css/bootstrap-responsive.css"
	type="text/css" />
<link rel="stylesheet" href="../assets/css/font-awesome.css"
	type="text/css" />
<script type="text/javascript" src="../../assets/js/jquery.min.js"></script>

<script type="text/javascript" src="../../assets/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="../../assets/js/bootstrap-popover.js"></script>
<script type="text/javascript"
	src="../../assets/js/bootstrap-tooltip.js"></script>
<script>
$(function ()
{ 
$("input").popover({trigger: 'focus', 'placement':'right'});

$("textarea").popover({trigger: 'focus'});


$('#tab').tooltip({'placement':'right', 'trigger' : 'hover'});

$('a').tooltip({'placement':'bottom', 'trigger' : 'hover'});
$('div.bar').tooltip({'placement':'top','trigger':'hover'});	
});
</script>
</head>
<?php
//open database
include 'config_open_db.php';
//include our awesome pagination
//class (library)
include 'ps_pagination.php';

//query all data anyway you want
//$sql = "select * from students ORDER BY stu_id DESC";
$sql = "SELECT * FROM main";
//execute query and get and

$rs = mysql_query( $sql ) or die('Database Error: ' . mysql_error() . ' ' . $sql );

//now, where gonna use our pagination class
//this is a significant part of our pagination
//i will explain the PS_Pagination parameters
//$conn is a variable from our config_open_db.php
//$sql is our sql statement above
//3 is the number of records retrieved per page
//4 is the number of page numbers rendered below
//null - i used null since in dont have any other
//parameters to pass (i.e. param1=valu1&param2=value2)
//you can use this if you're gonna use this class for search
//results since you will have to pass search keywords
$pager = new PS_Pagination( $conn, $sql, 30, 12, null );

//our pagination class will render new
//recordset (search results now are limited
//for pagination)
$rs = $pager->paginate();

//get retrieved rows to check if
//there are retrieved data
$num = mysql_num_rows( $rs );

if($num >= 1 ){
	//creating our table header

	echo "<table class='table table-bordered'>";
	$counter=1;
	echo "<tr><th>Serial Number</th><th>Project Name</th><th>Request Number</th><th>Status</th><th>Overall Progress&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th colspan='2' style='text-align:center'><i class='icon-cog'></i>&nbsp;Actions</th></tr>";
	//looping through the records retrieved
	while($row_pro = mysql_fetch_array( $rs )){
		$status=$row_pro['status'];
		$progress=0;
		switch($status){
			case 0:
				$status='Initiated';
				$progress="<div class='bar' style='width: 10%;' rel='tooltip' title='The overall progress of project is 10%!' data-placement='top'></div>";
				break;
			case 1:
				$status='Approved by MoE';
				$progress="<div class='bar' style='width: 30%;' rel='tooltip' title='The overall progress of project is 30%!' data-placement='top'></div>";
				break;
			case 2:
				$status='Budget Allocated';
				$progress="<div class='bar' style='width: 50%;' rel='tooltip' title='The overall progress of project is 50%!' data-placement='top'></div>";
				break;

			case 3:
				$status='Allotment Received';
				$progress="<div class='bar' style='width: 80%;' rel='tooltip' title='The overall progress of project is 80%!' data-placement='top'></div>";
				break;

			case 4:
				$status='Done';
				$progress="<div class='bar bar-success' style='width: 100%;' rel='tooltip' title='Good Job, the overall progress of project is 100%!' data-placement='top'></div>";
				break;

			default:
				$status='Undefined!';
		}
		echo "<tr>";
		echo "<td>" . $counter . "</td><td>" . $row_pro['proj_name'] . "</td><td>" . $row_pro['request_no'] . "</td><td>" . $status . "</td><td><div class='progress progress-striped'>" . $progress . "</div></td><td style='text-align:center'><a href='details.php?id=$row_pro[serial]'><i class='icon-eye-open'></i>&nbsp;Details</a></td><td style='text-align:center'><a href='update.php?id=$row_pro[serial]'><i class='icon-edit'></i>&nbsp;Update</a></td>";
		echo "</tr>";

		$counter++;

	}

	echo "</table>";

}else{
	//if no records found
	echo "No records found!";
}
//page-nav class to control
//the appearance of our page
//number navigation
echo "<div class='pagination'>";
//display our page number navigation
echo $pager->renderFullNav();
echo "</div>";

?>